﻿using IBLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        public IUserBLL Bll { get; }

        public UserController(IUserBLL bll)
        {
            Bll = bll;
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="m">用户信息表</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddA(Logth m)
        {
            return await Bll.AddA(m);
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="acction">用户名</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        [HttpGet]
        public Logth Logth(string acction, string pwd)
        {
            return Bll.Logth(acction, pwd);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="m">房态信息表</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> Add(User m)
        {
            return await Bll.Add(m);
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="PageIndex">当前页</param>
        /// <param name="PageSize">页容量</param>
        /// <param name="name">房态名称</param>
        /// <param name="num">房态编号</param>
        /// <returns></returns>
        [HttpGet]
        public ShowDTO Show(int PageIndex, int PageSize, string? name, int? num)
        {
           return Bll.Show(PageIndex, PageSize, name, num);
        }
        /// <summary>
        /// 删除逻辑
        /// </summary>
        /// <param name="uid">主键id</param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> del(int uid)
        {
            return await Bll.del(uid);  

        }
    }
}
